#ifndef PLAYER_H_
#define PLAYER_H_

#include "Entity.h"
#include "../KeyDefinitions.h"

namespace Facets {
	class Player : public virtual Entity {
			
		bool turningLeft, turningRight;
		bool movingForward,movingBackward;
						
		public:
			Player(const core::vector3df& pos, const core::vector3df& dir);
			Player(const core::vector3df& pos, const core::vector3df& dir, s32 ms);
			Player(const core::vector3df& pos, const core::vector3df& dir, s32 ms, s32 as, s32 ss);
			virtual ~Player();
			
			inline void setMovingBools() {
				turningLeft = turningRight =
					movingForward = movingBackward = false;
			}
			
			void handleInput(EKEY_CODE code, bool pressed) {
				switch(code) {
					case KEY_KEY_A: 
						turningLeft = pressed;
						break;
					case KEY_KEY_S:
						movingBackward = pressed;
						break;
					case KEY_KEY_D:
						turningRight = pressed;
						break;
					case KEY_KEY_W:
						movingForward = pressed;
						break;
					default: {
						Logger::Instance()->log("Player","Default on handleInput() reached.");
					}
				}
			}
			
			virtual void loadModel(const core::stringc& lulz) {
				Entity::loadModel(lulz);
//				m_Model->updateWeight(1);
			}
			
			void toggleName() {
				
			}
			
			virtual void update(float dt) {
				if(turningLeft) {
					m_Model->turnLeft(m_turnSpeed);
				} else
				if(turningRight) {
					m_Model->turnRight(m_turnSpeed);
				}

				if(movingForward) {
					m_Model->moveForward(m_MoveSpeed);
				} else
				if(movingBackward) {
					m_Model->moveBackward(m_MoveSpeed);
				} else
				m_Model->stopMoving();
				
				Entity::update(dt);
			}
	};
}

#endif /*PLAYER_H_*/
